package domain.controller;


import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.ServletException;
import javax.servlet.http.*;

import domain.data.QnAPersistenceManager;
import domain.model.Domain;


@SuppressWarnings("serial")

public class SitemapServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		
		PersistenceManager psm = QnAPersistenceManager.get().getPersistenceManager();

		Query query = psm.newQuery(Domain.class);
		query.setFilter("lastUpdateDate!=null");
		
		query.setOrdering("lastUpdateDate desc");
		query.setRange(0, 500);
		@SuppressWarnings("unchecked")
		List<Domain> domainList=  (List<Domain>)query.execute();

		req.setAttribute("domainList", domainList);
	
		try {
			req.getRequestDispatcher("/sitemap.jsp").forward(req, resp);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

